import geolocation from '@system.geolocation';
export default {
    data: {
        title: 'World'
    },
    getLocation(){
        geolocation.getLocation({
            success: function(data) {
                console.log('success get location data. latitude:' + data.latitude);
                console.log('success get location data. longitude:' + data.longitude);
            },
            fail: function(data, code) {
                console.log('fail to get location. code:' + code + ', data:' + data);
            },
        });
    },
    getLocationType(){
        geolocation.getLocationType({
            success: function(data) {
                console.log('success get location type:' + data.types[0]);
            },
            fail: function(data, code) {
                console.log('fail to get location. code:' + code + ', data:' + data);
            },
        });
    },
    subscribe(){
        geolocation.subscribe({
            success: function(data) {
                console.log('get location. latitude:' + data.latitude);
                console.log('get location data. longitude:' + data.longitude);
            },
            fail: function(data, code) {
                console.log('fail to get location. code:' + code + ', data:' + data);
            },
        });
    },
    unsubscribe(){
        geolocation.unsubscribe();
    },
    onDestroy(){
        this.unsubscribe()
    },
    getSupportedCoordTypes(){
        var types = geolocation.getSupportedCoordTypes();
        console.log(types)
    },
}
